var rootview = ui("$");
var app = sm("do_App");
var page = sm("do_Page");
var nf = sm("do_Notification");
var http = require("helper/http");
var pubUrl = require("url/pub");
var communityUtil = require("helper/community");
/*var openHelper = require("helper/open");
var bizzType = require("helper/bizzType");
var userUtil = require("helper/user");
var textContent = ui("textContent");
var httpSilence = require("helper/httpSilence");*/

var bizzId;
var bizzType;
var isPraised = 2;//是否关注 1-是，2-否
var shareTitle="",shareContent="",shareImage="",shareId,shareType;  //点赞

var praiseImg = ui("praiseImg");
var iconPraise = ["source://image/common/praise.png","source://image/common/praise1.png"];
//初始化
page.on("initPraise",function(data) {
	isPraised = data.isPraised;
	bizzId = data.bizzId;
	bizzType = data.bizzType;
	shareTitle=data.shareTitle;
	shareContent=data.shareContent;
	if(null!=data.shareImage){
		shareImage=data.shareImage;
	}
	shareType=data.shareType;
	shareId=data.shareId;
	if(data.isPraised==1){
		praiseImg.source = iconPraise[1];
	}	
});
//点赞
var footPraise = ui("footPraise");
footPraise.on("touch", "", 300,  function(data, e) {
	var addParams = {
        bizzId:bizzId,
        bizzType:bizzType,
        communityId:communityUtil.communityVisitId()
	};
	if(isPraised == 1){
		//如果已关注，再次点击则取消关注
		http.post(pubUrl.url.praise.doCancle,addParams,function(data){
			praiseImg.source = iconPraise[0];
			isPraised = 2;
			page.fire("onPraiseBack", data.praiseUserList);
		});
	}else{
		http.post(pubUrl.url.praise.doAdd,addParams,function(data){
			praiseImg.source = iconPraise[1];
			isPraised = 1;
			page.fire("onPraiseBack", data.praiseUserList);
		});
	}	
});
/*分享*/
var footShare = ui("footShare");
footShare.on("touch", "", 300, function() {
	page.fire("onShare",{showView:"true",shareTitle:shareTitle,shareContent:shareContent,shareId:shareId,shareType:shareType,shareImage:shareImage});
});

/*评论*/
var footComment = ui("footComment");
footComment.on("touch", "", 300, function() {
	var datas = {"bizzId":bizzId,"bizzType":bizzType,"beCommentedId":null};
	page.fire("bottomShow",datas);
});